package com.andrew.demo.mapper;

import com.andrew.demo.model.User;

import java.sql.ResultSet;
import java.sql.SQLException;


public class UserMapper implements BaseMapper<User> {

    public static final String SELECT_SQL = "select * from User";

    public static final String UPDATE_SQL = "update User set (name,age,sex) values (:name,:age,:sex)";

    @Override
    public User mapRow(ResultSet rs, int rowNum) throws SQLException {
        return convert(rs);
    }

    static User convert(ResultSet rs) throws SQLException {
        Integer id = rs.getInt("id");
        String name = rs.getString("name");
        Integer age = rs.getInt("age");
        String sex = rs.getString("sex");
        return new User(id, name, age, sex);
    }

}